package com.data.center.dictionary;


import com.data.center.exception.exception.BizException;
import com.data.center.exception.info.CommonEnum;

public enum EducationIsFullTime implements KeyValueMap {

    REVIEWED("0", "未知"),
    NOT_REVIEWED("1", "是"),
    EXPIRED("2", "否")
    ;

    /** 字典编码 */
    private String key;

    /** 字典 */
    private String value;

    EducationIsFullTime(String key, String value) {
        this.key = key;
        this.value = value;
    }

    @Override
    public String getKey() {
        return this.key;
    }

    @Override
    public String getValue() {
        return this.value;
    }

    /**
     * 根据key查询编码
     *
     * @param key
     */
    public static EducationIsFullTime getValueByKey(String key) {
        for (EducationIsFullTime myEnum : values()) {
            if (myEnum.key.equals(key)) {
                return myEnum;
            }
        }
        // 如果没有匹配项，直接抛出异常，防止业务忘记进行异常处理
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }

    /**
     * 根据编码反向查询key
     *
     * @param value
     */
    public static EducationIsFullTime getKeyByValue(String value) {
        for (EducationIsFullTime myEnum : values()) {
            if (myEnum.value.equals(value)) {
                return myEnum;
            }
        }
        // 如果没有匹配项，直接抛出异常，防止业务忘记进行异常处理
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }

}
